<?php

declare(strict_types=1);

namespace App\Request\User;

use Hyperf\Validation\Request\FormRequest;

class CardSaveRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'id' =>  'nullable',
            'card_name' => 'required',
            'card_level' => 'required',
            'card_color' => 'nullable',
            'card_cids' => 'nullable|array',
            'card_discount' => 'nullable',
            'card_desc' => 'nullable',
        ];
    }

    public function messages(): array
    {
        return [
            'card_name.required' => '会员卡名称不能为空',
            'card_level.required' => '会员卡等级不能为空',
            'card_cids.array' => '关联类目格式错误',
        ];
    }
}
